package com.thymeleaf.demo.util.result;


import com.alibaba.fastjson.JSONObject;
import com.thymeleaf.demo.util.Common;
import lombok.Data;

import java.io.Serializable;

@Data
public class BaseResult<T> implements Serializable {
    // 返回编码
    private Integer code;
    // 提示信息
    private String msg;
    // 返回值（内容）
    private T data;
    // 请求时间
    private int time;

    public BaseResult(){

    }

    BaseResult(Integer code, String msg, T data){
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.time = Common.getCurrent();
    }

    BaseResult(Integer code, String msg){
        this.code = code;
        this.msg = msg;
        this.data = (T)"";
        this.time = Common.getCurrent();
    }

    public String toString(){
        return JSONObject.toJSONString(this);
    }
}
